<template>
  <div class="content">
    <div class="title">
      <div class="text">
        <div class="font">企业人数分布</div>
      </div>
    </div>
    <div class="echart">
      <div id="inLine" style="width:100%;height:300px;" />
    </div>
  </div>
</template>

<script>
import { currentData } from '@/api/autonym'

export default {
  name: 'Firm',
  data() {
    return {
      data: {
        sign: 0,
        total: 0
      }
    }
  },
  mounted() {
    this.getDetail()
  },
  methods: {
    // 获取数据
    async getDetail() {
      const res = await currentData()
      if (res.code === 200) {
        if (res.data) {
          this.data = res.data
        }
        this.$nextTick(function() {
          this.drawPie()
        })
      }
    },
    drawPie() {
      const myChart = this.$echarts.init(document.getElementById('inLine'))
      const Userdatas = [
        { name: '企业1', value: 409.6, itemStyle: { color: '#3BA0FF' }},
        { name: '企业2', value: 204.8, itemStyle: { color: '#EECB5F' }},
        { name: '企业3', value: 225.28, itemStyle: { color: '#D29A00' }},
        { name: '企业4', value: 225.28, itemStyle: { color: '#36CBCB' }},
        { name: '企业5', value: 184.32, itemStyle: { color: '#99E087' }}
      ]
      const option = {
        legend: {
          orient: 'vertical',
          top: '30%',
          left: '70%',
          // x:'right',      //可设定图例在左、右、居中
          // y:'center',     //可设定图例在上、下、居中
          icon: 'circle', // 可设定图例[距上方距离，距右方距离，距下方距离，距左方距离]
          data: ['企业1', '企业2', '企业3', '企业4', '企业5'],
          textStyle: {
            color: '#ffffff',
            fontSize: 12,
            align: 'left',
            padding: 2
          }
        },
        series: [{
          name: '访问来源',
          type: 'pie',
          radius: '65%',
          left: '-40%',
          center: ['50%', '50%'],
          data: Userdatas,
          roseType: 'radius',
          label: {
            normal: {
              show: true,
              position: 'inner',
              formatter: '{per|{d}%}',
              rich: {
                b: {
                  fontSize: 14,
                  lineHeight: 33
                },
                per: {
                  color: 'white'
                }
              }
            }
          }

        }]
      }
      myChart.setOption(option, window.onresize = myChart.resize)
    }
  }
}
</script>

<style lang="scss" scoped>
.content{
  // color: #ffffff;
  // border: 1px solid rgba(221,221,221,0.2);
  margin: 0;
  padding: 10px;
  .title{
    display: flex;
    .text{
      flex: 1;
      text-align: left;
      .font{
        color:#ffffff;
        cursor: pointer;
        font-size: 12px;
        font-weight: 400;
        padding: 5px 0;
        .number{
          font-size:14px;
          font-weight:500;
          color:rgba(255,255,255,0.85);
        }
      }
      .money{
         font-size: 12px;
        font-weight: 400;
        color: #ffffff;
      }
    }
  }
  .echart{
    // height: 70px;
    margin: 0 0 32px 0;
  }
  .name{
    margin-top: -60px;
    text-align: center;
    color:rgba(255,255,255,1);
    .text{
      text-align: center;
      margin-bottom: 6px;
      .bground{
        width:8px;
        height:8px;
        background:rgba(210,154,0,1);
        border-radius: 4px;
        float: left;
        margin-left: 27%;
        margin-top: 5px;
      }
    }
  }
}
</style>
